﻿using IterationLife.Educations.Models;
using Util;
using Util.Maps;

namespace IterationLife.PlatformBackEnd.AppServices.Dtos.Educations {
    /// <summary>
    /// 科目数据传输对象扩展
    /// </summary>
    public static class SubjectDtoExtension {
        /// <summary>
        /// 转换为科目实体
        /// </summary>
        /// <param name="dto">科目数据传输对象</param>
        public static Subject ToEntity( this SubjectDto dto ) {
            if ( dto == null )
                return new Subject();
            return dto.MapTo( new Subject( dto.Id.ToGuid() ) );
        }
        
        /// <summary>
        /// 转换为科目数据传输对象
        /// </summary>
        /// <param name="entity">科目实体</param>
        public static SubjectDto ToDto(this Subject entity) {
            if( entity == null )
                return new SubjectDto();
            return entity.MapTo(new SubjectDto());
        }
    }
}
